/** 
 * Copyright 2010 Erlacher Felix, Estgfaeller Wolfgang, Ferula Patrick
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package at.socialconference.app.uihelper;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;

public class AlertHelper {
	/**
	 * Displays an Alert
	 * 
	 * @param title
	 *            Title of Alert
	 * @param message
	 *            Message of Alert
	 * @param exit
	 *            If true exit activity if user clicks on ok
	 */
	public static void alert(String title, String message, final boolean exit, final Activity activity) {
		AlertDialog alertDialog = new AlertDialog.Builder(activity).create();

		alertDialog.setTitle(title);

		alertDialog.setMessage(message);
		alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
				if (exit) {
					activity.finish();
				}
				return;
			}
		});
		alertDialog.show();
	}
}
